package com.quectel.aiot.service.impl;

import com.quectel.aiot.entity.Voice;
import com.quectel.aiot.mapper.VoiceMapper;
import com.quectel.aiot.service.VoiceService;
import com.quectel.aiot.util.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;

@Service
public class VoiceServiceImpl implements VoiceService {
    @Autowired
    private VoiceMapper voiceMapper;

    private static final SnowflakeIdWorker idWorker = new SnowflakeIdWorker(1, 1);

    @Override
    public Voice getVoiceById(Long id) {
        return voiceMapper.selectVoiceById(id);
    }

    @Override
    public List<Voice> getVoiceList() {
        return voiceMapper.selectVoiceList();
    }

    @Override
    public void addVoice(Voice voice) {
        voice.setId(idWorker.nextId());
        voice.setCreatedTime(new Date());
        voiceMapper.insertVoice(voice);
    }

    @Override
    public int updateVoice(Voice voice) {
        return voiceMapper.updateVoice(voice);
    }

    @Override
    public int deleteVoice(Long id) {
        return voiceMapper.deleteVoice(id);
    }
} 